package com.heima.admin.job;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.feigns.wemedia.WemediaFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class WeMediaNewsAutoScanJob {
    @Autowired
    WemediaFeign wemediaFeign;
    @Autowired
    WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @XxlJob("autoScanByMediaNewsId")
    public ReturnT<String> autoScanJob(String param) throws Exception {
        log.info("****WeMediaNewsAutoScanJob autoScanJob****");
        List<Integer> list = wemediaFeign.findRelease();//id集合
        log.info("wmNewsId:{}",list);
        if (list != null && list.size() > 0) {
            for (Integer id : list) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);//发布
            }

        }
        log.info("自媒体文章定时审核发布成功");
        return ReturnT.SUCCESS;
    }
}
